-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merge master to stage from master #1697
base: staging
Are you sure you want to change the base?
Conversation
WalkthroughThe updates introduce several enhancements and refactorings across the codebase. Key changes include adding new columns to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant DonationRepository
participant DonationService
participant Database
User->>+DonationRepository: countUniqueDonors(projectId)
DonationRepository->>Database: Query unique donors count
Database-->>DonationRepository: Result
DonationRepository-->>-User: Count of unique donors
User->>+DonationService: updateOldStableCoinDonationsPrice()
DonationService->>DonationRepository: findStableCoinDonationsWithoutPrice()
DonationRepository->>Database: Query stable coin donations without price
Database-->>DonationRepository: Result
DonationRepository-->>DonationService: List of donations
DonationService->>Database: Update donations with historic prices
Database-->>DonationService: Update result
DonationService-->>-User: Update complete
sequenceDiagram
participant Migration
participant Database
Migration->>+Database: Add columns to draft_donation table
Database-->>-Migration: Columns added
Poem
Recent review detailsConfiguration used: CodeRabbit UI Files selected for processing (4)
Additional context usedBiome
Additional comments not posted (28)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
function findStableCoinDonationsWithoutPriceTestCases() { | ||
it('should just return stable coin donations without price', async () => { | ||
const project = await saveProjectDirectlyToDb(createProjectData()); | ||
const donor = await saveUserDirectlyToDb(generateRandomEtheriumAddress()); | ||
|
||
const donationData1 = { ...createDonationData(), currency: 'USDC' }; | ||
delete donationData1.valueUsd; | ||
|
||
const donationData2 = { ...createDonationData(), currency: 'USDC' }; | ||
|
||
const donationData3 = { ...createDonationData(), currency: 'USDT' }; | ||
delete donationData3.valueUsd; | ||
|
||
const donationData4 = { ...createDonationData(), currency: 'USDT' }; | ||
donationData4.currency = 'USDT'; | ||
|
||
const donationData5 = { | ||
...createDonationData(), | ||
currency: 'WXDAI', | ||
transactionNetworkId: NETWORK_IDS.XDAI, | ||
}; | ||
delete donationData5.valueUsd; | ||
|
||
const donationData6 = { | ||
...createDonationData(), | ||
currency: 'WXDAI', | ||
transactionNetworkId: NETWORK_IDS.XDAI, | ||
}; | ||
|
||
const donationData7 = { | ||
...createDonationData(), | ||
currency: 'WXDAI', | ||
transactionNetworkId: NETWORK_IDS.XDAI, | ||
}; | ||
delete donationData7.valueUsd; | ||
|
||
const donationData8 = { | ||
...createDonationData(), | ||
currency: 'WXDAI', | ||
transactionNetworkId: NETWORK_IDS.XDAI, | ||
}; | ||
|
||
const donationData9 = createDonationData(); | ||
delete donationData9.valueUsd; | ||
|
||
await saveDonationDirectlyToDb(donationData1, donor.id, project.id); | ||
await saveDonationDirectlyToDb(donationData2, donor.id, project.id); | ||
await saveDonationDirectlyToDb(donationData3, donor.id, project.id); | ||
await saveDonationDirectlyToDb(donationData4, donor.id, project.id); | ||
await saveDonationDirectlyToDb(donationData5, donor.id, project.id); | ||
await saveDonationDirectlyToDb(donationData6, donor.id, project.id); | ||
await saveDonationDirectlyToDb(donationData7, donor.id, project.id); | ||
await saveDonationDirectlyToDb(donationData8, donor.id, project.id); | ||
await saveDonationDirectlyToDb(donationData9, donor.id, project.id); | ||
|
||
const donations = await findStableCoinDonationsWithoutPrice(); | ||
assert.equal(donations.length, 4); | ||
assert.isOk( | ||
donations.find( | ||
donation => donation.transactionId === donationData1.transactionId, | ||
), | ||
); | ||
assert.isOk( | ||
donations.find( | ||
donation => donation.transactionId === donationData3.transactionId, | ||
), | ||
); | ||
assert.isOk( | ||
donations.find( | ||
donation => donation.transactionId === donationData5.transactionId, | ||
), | ||
); | ||
assert.isOk( | ||
donations.find( | ||
donation => donation.transactionId === donationData7.transactionId, | ||
), | ||
); | ||
|
||
await updateOldStableCoinDonationsPrice(); | ||
|
||
// Shoud fill valuUsd of all stable coin donations | ||
const stableDonationsWithoutPrice = | ||
await findStableCoinDonationsWithoutPrice(); | ||
assert.isEmpty(stableDonationsWithoutPrice); | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using the delete
operator for performance reasons.
The delete
operator can impact performance. Instead, consider setting the property to undefined
.
- delete donationData1.valueUsd;
+ donationData1.valueUsd = undefined;
- delete donationData3.valueUsd;
+ donationData3.valueUsd = undefined;
- delete donationData5.valueUsd;
+ donationData5.valueUsd = undefined;
- delete donationData7.valueUsd;
+ donationData7.valueUsd = undefined;
- delete donationData9.valueUsd;
+ donationData9.valueUsd = undefined;
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
function findStableCoinDonationsWithoutPriceTestCases() { | |
it('should just return stable coin donations without price', async () => { | |
const project = await saveProjectDirectlyToDb(createProjectData()); | |
const donor = await saveUserDirectlyToDb(generateRandomEtheriumAddress()); | |
const donationData1 = { ...createDonationData(), currency: 'USDC' }; | |
delete donationData1.valueUsd; | |
const donationData2 = { ...createDonationData(), currency: 'USDC' }; | |
const donationData3 = { ...createDonationData(), currency: 'USDT' }; | |
delete donationData3.valueUsd; | |
const donationData4 = { ...createDonationData(), currency: 'USDT' }; | |
donationData4.currency = 'USDT'; | |
const donationData5 = { | |
...createDonationData(), | |
currency: 'WXDAI', | |
transactionNetworkId: NETWORK_IDS.XDAI, | |
}; | |
delete donationData5.valueUsd; | |
const donationData6 = { | |
...createDonationData(), | |
currency: 'WXDAI', | |
transactionNetworkId: NETWORK_IDS.XDAI, | |
}; | |
const donationData7 = { | |
...createDonationData(), | |
currency: 'WXDAI', | |
transactionNetworkId: NETWORK_IDS.XDAI, | |
}; | |
delete donationData7.valueUsd; | |
const donationData8 = { | |
...createDonationData(), | |
currency: 'WXDAI', | |
transactionNetworkId: NETWORK_IDS.XDAI, | |
}; | |
const donationData9 = createDonationData(); | |
delete donationData9.valueUsd; | |
await saveDonationDirectlyToDb(donationData1, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData2, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData3, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData4, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData5, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData6, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData7, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData8, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData9, donor.id, project.id); | |
const donations = await findStableCoinDonationsWithoutPrice(); | |
assert.equal(donations.length, 4); | |
assert.isOk( | |
donations.find( | |
donation => donation.transactionId === donationData1.transactionId, | |
), | |
); | |
assert.isOk( | |
donations.find( | |
donation => donation.transactionId === donationData3.transactionId, | |
), | |
); | |
assert.isOk( | |
donations.find( | |
donation => donation.transactionId === donationData5.transactionId, | |
), | |
); | |
assert.isOk( | |
donations.find( | |
donation => donation.transactionId === donationData7.transactionId, | |
), | |
); | |
await updateOldStableCoinDonationsPrice(); | |
// Shoud fill valuUsd of all stable coin donations | |
const stableDonationsWithoutPrice = | |
await findStableCoinDonationsWithoutPrice(); | |
assert.isEmpty(stableDonationsWithoutPrice); | |
}); | |
} | |
function findStableCoinDonationsWithoutPriceTestCases() { | |
it('should just return stable coin donations without price', async () => { | |
const project = await saveProjectDirectlyToDb(createProjectData()); | |
const donor = await saveUserDirectlyToDb(generateRandomEtheriumAddress()); | |
const donationData1 = { ...createDonationData(), currency: 'USDC' }; | |
donationData1.valueUsd = undefined; | |
const donationData2 = { ...createDonationData(), currency: 'USDC' }; | |
const donationData3 = { ...createDonationData(), currency: 'USDT' }; | |
donationData3.valueUsd = undefined; | |
const donationData4 = { ...createDonationData(), currency: 'USDT' }; | |
donationData4.currency = 'USDT'; | |
const donationData5 = { | |
...createDonationData(), | |
currency: 'WXDAI', | |
transactionNetworkId: NETWORK_IDS.XDAI, | |
}; | |
donationData5.valueUsd = undefined; | |
const donationData6 = { | |
...createDonationData(), | |
currency: 'WXDAI', | |
transactionNetworkId: NETWORK_IDS.XDAI, | |
}; | |
const donationData7 = { | |
...createDonationData(), | |
currency: 'WXDAI', | |
transactionNetworkId: NETWORK_IDS.XDAI, | |
}; | |
donationData7.valueUsd = undefined; | |
const donationData8 = { | |
...createDonationData(), | |
currency: 'WXDAI', | |
transactionNetworkId: NETWORK_IDS.XDAI, | |
}; | |
const donationData9 = createDonationData(); | |
donationData9.valueUsd = undefined; | |
await saveDonationDirectlyToDb(donationData1, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData2, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData3, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData4, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData5, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData6, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData7, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData8, donor.id, project.id); | |
await saveDonationDirectlyToDb(donationData9, donor.id, project.id); | |
const donations = await findStableCoinDonationsWithoutPrice(); | |
assert.equal(donations.length, 4); | |
assert.isOk( | |
donations.find( | |
donation => donation.transactionId === donationData1.transactionId, | |
), | |
); | |
assert.isOk( | |
donations.find( | |
donation => donation.transactionId === donationData3.transactionId, | |
), | |
); | |
assert.isOk( | |
donations.find( | |
donation => donation.transactionId === donationData5.transactionId, | |
), | |
); | |
assert.isOk( | |
donations.find( | |
donation => donation.transactionId === donationData7.transactionId, | |
), | |
); | |
await updateOldStableCoinDonationsPrice(); | |
// Shoud fill valuUsd of all stable coin donations | |
const stableDonationsWithoutPrice = | |
await findStableCoinDonationsWithoutPrice(); | |
assert.isEmpty(stableDonationsWithoutPrice); | |
}); | |
} |
Tools
Biome
[error] 388-388: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 393-393: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 403-403: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 416-416: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
[error] 425-425: Avoid the delete operator which can impact performance.
Unsafe fix: Use an undefined assignment instead.
(lint/performance/noDelete)
Summary by CodeRabbit
New Features
Improvements
Bug Fixes
Tests